package com.tac.service.mes.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tac.common.result.Result;
import com.tac.dao.mes.IncomingInspectionDao;
import com.tac.pojo.mes.IncomingInspection;
import com.tac.service.mes.IncomingInspectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class IncomingInspectionServiceImpl implements IncomingInspectionService {

    @Autowired
    private IncomingInspectionDao incomingInspectionDao;

    //来料检验查看
    public Result<PageInfo<IncomingInspection>> getList(Integer pageNum, Integer pageSize, Integer serialNumber, Integer materialApplicationId, Integer materialId, String inspector,
                          Date inspectionTimeStart, Date inspectionTimeEnd){
        PageHelper.startPage(pageNum,pageSize);
        List<IncomingInspection> list = incomingInspectionDao.getList(serialNumber, materialApplicationId, materialId, inspector, inspectionTimeStart, inspectionTimeEnd);
        PageInfo<IncomingInspection> incomingInspectionPageInfo = new PageInfo<>(list);
        return Result.success(incomingInspectionPageInfo);
    }
    //来料检验添加
    public Result save(IncomingInspection incomingInspection){
        Integer integer = incomingInspectionDao.save(incomingInspection);
        if(integer<=0){
            return Result.error("来料检验添加失败");
        }else {
            return Result.success(null);
        }
    }

    //来料检验删除
    public Result remove(List<Integer> ids){
        Integer integer = incomingInspectionDao.remove(ids);
        if(integer<=0){
            return Result.error("来料检验删除失败");
        }else {
            return Result.success(null);
        }
    }
    //来料检验更新
    public Result update(IncomingInspection incomingInspection){
        Integer integer = incomingInspectionDao.update(incomingInspection);
        if(integer<=0){
            return Result.error("来料检验更新失败");
        }else {
            return Result.success(null);
        }
    }
}
